<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>考试管理 - 智能教育系统</title>
    <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
    <style>
        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
            margin: 0;
            padding-top: 80px;
        }

        .exam-container {
            max-width: 1200px;
            margin: 2rem auto;
            padding: 2rem;
            animation: fadeIn 0.5s ease;
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        .exam-card {
            background: white;
            border-radius: 15px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
            cursor: pointer;
        }

        .exam-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(45deg, transparent, rgba(110, 142, 251, 0.1), transparent);
            transform: translateX(-100%);
            transition: transform 0.5s ease;
        }

        .exam-card:hover::before {
            transform: translateX(100%);
        }

        .exam-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
        }

        .btn-primary {
            background: linear-gradient(135deg, #6e8efb, #a777e3);
            color: white;
            padding: 0.75rem 1.5rem;
            border-radius: 25px;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
            border: none;
            font-weight: 600;
        }

        .btn-primary::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(45deg, transparent, rgba(255,255,255,0.2), transparent);
            transform: translateX(-100%);
            transition: transform 0.5s ease;
        }

        .btn-primary:hover::before {
            transform: translateX(100%);
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(110, 142, 251, 0.3);
        }

        .alert {
            padding: 1rem;
            border-radius: 8px;
            margin-bottom: 1rem;
            animation: slideIn 0.3s ease;
            position: relative;
            overflow: hidden;
        }

        .alert::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(45deg, transparent, rgba(255,255,255,0.2), transparent);
            transform: translateX(-100%);
            transition: transform 0.5s ease;
        }

        .alert:hover::before {
            transform: translateX(100%);
        }

        @keyframes slideIn {
            from {
                transform: translateY(-10px);
                opacity: 0;
            }
            to {
                transform: translateY(0);
                opacity: 1;
            }
        }

        .exam-info {
            padding: 1.5rem;
        }

        .exam-title {
            font-size: 1.25rem;
            font-weight: 600;
            color: #2d3748;
            margin-bottom: 0.5rem;
            transition: color 0.3s ease;
        }

        .exam-card:hover .exam-title {
            color: #6e8efb;
        }

        .exam-meta {
            color: #718096;
            font-size: 0.875rem;
            margin-bottom: 1rem;
        }

        .exam-actions {
            display: flex;
            gap: 1rem;
            margin-top: 1rem;
            opacity: 0;
            transform: translateY(10px);
            transition: all 0.3s ease;
        }

        .exam-card:hover .exam-actions {
            opacity: 1;
            transform: translateY(0);
        }

        .action-btn {
            padding: 0.5rem 1rem;
            border-radius: 20px;
            font-size: 0.875rem;
            font-weight: 500;
            transition: all 0.3s ease;
        }

        .action-btn.edit {
            background: rgba(110, 142, 251, 0.1);
            color: #6e8efb;
        }

        .action-btn.edit:hover {
            background: rgba(110, 142, 251, 0.2);
            transform: translateY(-2px);
        }

        .action-btn.delete {
            background: rgba(255, 107, 107, 0.1);
            color: #ff6b6b;
        }

        .action-btn.delete:hover {
            background: rgba(255, 107, 107, 0.2);
            transform: translateY(-2px);
        }

        .empty-state {
            text-align: center;
            padding: 3rem;
            background: white;
            border-radius: 15px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            animation: fadeIn 0.5s ease;
        }

        .empty-state-icon {
            font-size: 3rem;
            color: #cbd5e0;
            margin-bottom: 1rem;
        }

        .empty-state-text {
            color: #718096;
            font-size: 1.1rem;
        }
    </style>
</head>
<body>
    <!-- 引入导航栏 -->
    <div th:replace="fragments/navbar :: navbar"></div>

    <div class="exam-container">
        <div class="flex justify-between items-center mb-6">
            <h1 class="text-3xl font-bold text-gray-800">考试管理</h1>
            <a href="/exam/create" class="btn-primary">创建新考试</a>
        </div>

        <!-- 提示消息 -->
        <div th:if="${success}" class="alert bg-green-100 text-green-700" th:text="${success}"></div>
        <div th:if="${error}" class="alert bg-red-100 text-red-700" th:text="${error}"></div>

        <!-- 考试列表 -->
        <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
            <div th:each="exam : ${exams}" class="exam-card">
                <div class="exam-info">
                    <h3 class="exam-title" th:text="${exam.examName}">考试名称</h3>
                    <div class="exam-meta">
                        <p th:text="${'科目：' + exam.subject}">科目</p>
                        <p th:text="${'考试日期：' + #temporals.format(exam.examDate, 'yyyy-MM-dd HH:mm')}">考试日期</p>
                        <p th:text="${'班级：' + exam.classEntity.className + ' (' + exam.classEntity.grade + ')'}">班级</p>
                    </div>
                    <div class="exam-actions">
                        <a th:href="@{/exam/edit/{id}(id=${exam.id})}" 
                           class="action-btn edit">
                            编辑
                        </a>
                        <form th:action="@{/exam/delete/{id}(id=${exam.id})}" 
                              method="post" 
                              class="inline"
                              onsubmit="return confirm('确定要删除这个考试吗？');">
                            <button type="submit" class="action-btn delete">
                                删除
                            </button>
                        </form>
                    </div>
                </div>
            </div>
        </div>

        <!-- 空状态 -->
        <div th:if="${#lists.isEmpty(exams)}" class="empty-state">
            <div class="empty-state-icon">📝</div>
            <p class="empty-state-text">暂无考试记录</p>
        </div>
    </div>

    <script>
        // 添加页面滚动效果
        window.addEventListener('scroll', function() {
            const examCards = document.querySelectorAll('.exam-card');
            const scrollPosition = window.scrollY;
            
            examCards.forEach((card, index) => {
                if (scrollPosition > 100) {
                    card.style.transform = `translateY(-${Math.min(5, index * 0.5)}px)`;
                } else {
                    card.style.transform = 'translateY(0)';
                }
            });
        });

        // 添加考试卡片点击效果
        document.querySelectorAll('.exam-card').forEach(card => {
            card.addEventListener('click', function(e) {
                if (!e.target.closest('.action-btn')) {
                    const editLink = this.querySelector('.action-btn.edit');
                    if (editLink) {
                        editLink.click();
                    }
                }
            });
        });
    </script>
</body>
</html> 